package com.cskaoyan.controller;

import com.cskaoyan.bean.PO.MarketKeyword;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.mapper.MarketKeywordMapper;
import com.cskaoyan.service.AdminKeywordsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AdminKeywordController
 * @Description TODO
 * @Author ke
 * @Date 2022/8/13 18:08
 * @Version 1.0
 */
@RestController
@RequestMapping("admin/keyword")
public class AdminKeywordController {

    @Autowired
    AdminKeywordsService adminKeywordsService;

    @RequiresPermissions("admin:keyword:list")
    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info,String keyword,String url){
        CommonData<MarketKeyword> keywordCommonData=adminKeywordsService.list(info,keyword,url);
        return BaseRespVo.ok(0,keywordCommonData,"成功");
    }

    @RequiresPermissions("admin:keyword:create")
    @RequestMapping("create")
    public BaseRespVo create(@RequestBody MarketKeyword bo){
        MarketKeyword vo=adminKeywordsService.create(bo);
        return BaseRespVo.ok(0,vo,"成功");
    }

    @RequiresPermissions("admin:keyword:update")
    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketKeyword bo ){
        MarketKeyword vo=adminKeywordsService.update(bo);
        return BaseRespVo.ok(0,vo,"成功");
    }

    @RequiresPermissions("admin:keyword:delete")
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketKeyword bo){
        MarketKeyword vo=adminKeywordsService.delete(bo);
        return BaseRespVo.ok(0,null,"成功");
    }
}
